package com.haibara.codesubmiteval.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.haibara.codesubmiteval.model.entity.Question;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author AiChan
 * @description 针对表【question(题目)】的数据库操作Mapper
 * @createDate 2024-12-20 13:17:24
 * @Entity com.haibara.condesubmiteval.model.entity.Question
 */
public interface QuestionMapper extends BaseMapper<Question> {

    @Update("update question set submit = submit + 1 , ratio = (accepted/submit) * 100 where id = #{id}")
    int increaseQuestionSubmitNum(Long id);

    @Update("update question set accepted = accepted + 1 , ratio = (accepted/submit) * 100 where id = #{id}")
    void increaseQuestionAcceptedNum(Long id);

    @Select("select count(*) from question where isDelete = 0")
    int getQuestionNumber();

    List<Question> selectTop3Questions(Boolean isHardest);
}




